using UnityEngine;

public class DialogTweener : MonoBehaviour
{
	public UITweener[] dismissActions;

	public bool dismissAllTweenAttachedThisGameObject = true;

	public UITweener[] showActions;

	public bool showAllTweenAttachedThisGameObject = true;

	private void Awake()
	{
		if (dismissAllTweenAttachedThisGameObject)
		{
			dismissActions = base.transform.GetComponents<UITweener>();
		}
		if (showAllTweenAttachedThisGameObject)
		{
			showActions = base.transform.GetComponents<UITweener>();
		}
	}

	private void OnEnable()
	{
		for (int i = 0; i < dismissActions.Length; i++)
		{
			dismissActions[i].enabled = false;
		}
		for (int j = 0; j < showActions.Length; j++)
		{
			if (showActions[j] is TweenScale)
			{
				TweenScale tweenScale = showActions[j] as TweenScale;
				tweenScale.from.Set(1f, 1f, 1f);
				tweenScale.to.Set(1.1f, 1.1f, 1.1f);
				tweenScale.duration = 0.2f;
			}
			else if (showActions[j] is TweenAlpha)
			{
				TweenAlpha tweenAlpha = showActions[j] as TweenAlpha;
				tweenAlpha.from = 0f;
				tweenAlpha.to = 1f;
				tweenAlpha.delay = 0f;
				tweenAlpha.duration = 0.3f;
			}
			showActions[j].enabled = true;
			showActions[j].PlayForward();
			showActions[j].ResetToBeginning();
			showActions[j].PlayForward();
		}
	}

	public void Dismiss()
	{
		for (int i = 0; i < dismissActions.Length; i++)
		{
			if (showActions[i] is TweenScale)
			{
				TweenScale tweenScale = showActions[i] as TweenScale;
				tweenScale.from.Set(1f, 1f, 1f);
				tweenScale.to.Set(1.1f, 1.1f, 1.1f);
				tweenScale.duration = 0.2f;
			}
			else if (dismissActions[i] is TweenAlpha)
			{
				TweenAlpha tweenAlpha = dismissActions[i] as TweenAlpha;
				tweenAlpha.from = 0f;
				tweenAlpha.to = 1f;
				tweenAlpha.delay = 0.1f;
				tweenAlpha.duration = 0.1f;
			}
			dismissActions[i].enabled = true;
			dismissActions[i].PlayReverse();
			dismissActions[i].ResetToBeginning();
		}
	}
}
